package year2019.month11.singleton;

/**
 * @desc 描述
 * create on 2018/11/6 by watson
 */
public class MainTest {

    public static void main(String[] args){
        Thread thread1 = new Thread(new TestThread());
        Thread thread2 = new Thread(new TestThread());
        Thread thread3 = new Thread(new TestThread());
        Thread thread4 = new Thread(new TestThread());
        Thread thread5 = new Thread(new TestThread());
        Thread thread6 = new Thread(new TestThread());
        Thread thread7 = new Thread(new TestThread());
        Thread thread8 = new Thread(new TestThread());
        Thread thread9 = new Thread(new TestThread());
        Thread thread10 = new Thread(new TestThread());
        Thread thread11 = new Thread(new TestThread());
        Thread thread12 = new Thread(new TestThread());
        Thread thread13 = new Thread(new TestThread());
        Thread thread14 = new Thread(new TestThread());
        Thread thread15 = new Thread(new TestThread());
        Thread thread16 = new Thread(new TestThread());
        Thread thread17 = new Thread(new TestThread());
        Thread thread18 = new Thread(new TestThread());
        thread1.start();
        thread2.start();
        thread3.start();
        thread4.start();
        thread5.start();
        thread6.start();
        thread7.start();
        thread8.start();
        thread9.start();
        thread10.start();
        thread11.start();
        thread12.start();
        thread13.start();
        thread14.start();
        thread15.start();
        thread16.start();
        thread17.start();
        thread18.start();
    }

    public static void testLazySingleton(String str){
        LazySingleton lazySingleton = LazySingleton.getLazySingleton();
        System.out.println(lazySingleton.getStr());
    }

    public static void testEagerSingleton(){
        EagerSingleton eagerSingleton = EagerSingleton.getEagerSingleton();
        System.out.println(eagerSingleton.getStr());
    }

}

class TestThread implements Runnable{

    @Override
    public void run() {
//        LazySingleton lazySingleton = LazySingleton.getLazySingleton();
//        System.out.println(lazySingleton.getStr());
        LazySingleton lazy = LazySingleton.getLazy();
        System.out.println(lazy);
    }

}